home *** CD-ROM | disk | FTP | other *** search
- //: :purge.h
- // From Thinking in C++, 2nd Edition
- // Available at http://www.BruceEckel.com
- // (c) Bruce Eckel 1999
- // Copyright notice in Copyright.txt
- // Delete pointers in an STL sequence container
- #ifndef PURGE_H
- #define PURGE_H
- #include <algorithm>
-
- template<class Seq> void purge(Seq& c) {
- typename Seq::iterator i;
- for(i = c.begin(); i != c.end(); i++) {
- delete *i;
- *i = 0;
- }
- }
-
- // Iterator version:
- template<class InpIt>
- void purge(InpIt begin, InpIt end) {
- while(begin != end) {
- delete *begin;
- *begin = 0;
- begin++;
- }
- }
- #endif // PURGE_H ///:~
-